package com.xjh.basestudy.javabase.Collection;

public class ChangeArgs {
    public static void main(String[] args) {
        System.out.println(sums(1));
        System.out.println(sums(1, 2));
        System.out.println(sums(1, 2, 3));
        System.out.println(sums(1, 2, 3, 4));


    }

    public static int sums(int... a) {//a实际上是一个数组，它把参数都放在数组里了
//        public static int sums(int b,int... DruidDemo) {//注意，如果有多个参数，可变参数要放到最后
//        System.out.println(DruidDemo);
//        return 0;
        int sum = 0;
        for (int i : a) {
            sum += i;

        }
        return sum;
    }
}
